home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / DLGoodies / touch.dopus5 < prev   
Text File  |  1996-08-29  |  3KB  |  108 lines

  1. /*
  2.  * Touch: Unix-like touch command which either
  3.  *         1) Sets the date-stamp of all selected entries in source listers 
  4.  *            to the current date and time, or
  5.  *         2) creates a new (empty) file if no entries are selected. User
  6.  *            is prompted via requester.
  7.  *
  8.  * Call:  ARexx  DOpus5:ARexx/Touch.dopus5 {Qp}
  9.  *
  10.  *  Touch.dopus5  v1.0
  11.  *    By David Lübbren, 1.7.96
  12.  *    EMail: uhay@rz.uni-karlsruhe.de
  13.  */
  14.  
  15.  
  16. PARSE ARG dopusport
  17.  
  18. IF dopusport ~= "" THEN ADDRESS VALUE dopusport
  19. ELSE DO
  20.   SAY "DOpus5 is NOT running !"
  21.   EXIT
  22. END
  23.  
  24. OPTIONS RESULTS
  25.  
  26. lister query source
  27. IF rc > 0 THEN DO
  28.   Beep
  29.   EXIT
  30. END
  31.  
  32. PARSE VAR result handle .
  33.  
  34.  
  35. lister set handle busy on
  36.  
  37. lister query handle path
  38. IF rc = 0 THEN DO
  39.   SourcePath = STRIP(result, 'B', '"')
  40.   lister query handle selentries stem Entry.
  41.   IF rc = 0 THEN DO
  42.     IF Entry.count > 0 THEN DO
  43.       lister set handle progress Entry.count 'Touching...'
  44.       lister set handle title 'Touching...'
  45.       lister refresh handle full
  46.       
  47.       DO i=0 TO Entry.count-1
  48.         lister query handle abort
  49.         IF result THEN
  50.           SIGNAL quitit
  51.  
  52.         lister set handle progress count i+1
  53.         lister set handle progress name Entry.i
  54.  
  55.         ADDRESS COMMAND 'SetDate ' || '"' || SourcePath || Entry.i || '"'
  56.  
  57.         lister select handle '"' || Entry.i || '"' off
  58.         lister refresh handle
  59.       END
  60.     END
  61.     ELSE DO
  62.       DO UNTIL again = 0
  63.         again = 0
  64.         dopus getstring '"Filename to create:" 255 "" Ok|Cancel'
  65.         IF dopusrc ~= 0 THEN DO
  66.           name = STRIP(result, 'B', '"')
  67.           divpos = MAX(LASTPOS(':', name),LASTPOS('/', name))
  68.           IF divpos > 0 THEN name = SUBSTR(name, divpos + 1)
  69.           FullName = SourcePath || name
  70.           lister query handle entry '"'name'"'
  71.           IF rc = 0 THEN DO
  72.             dopus request '"Error: '''name''' already exists" Again|Cancel'
  73.             again = rc
  74.           END
  75.           ELSE DO
  76.             IF OPEN('fp', FullName, 'w') THEN DO
  77.               CLOSE('fp')
  78.               lister set handle busy off
  79.               lister read handle '"'SourcePath'"' force
  80.               lister wait handle
  81.               lister set handle busy on
  82.               lister select handle '"'name'"' on
  83.               IF rc ~= 0 THEN DO
  84.                 dopus request '"Konnte '''name''' nicht selectieren" Ok'
  85.               END
  86.               again = 0
  87.             END
  88.             ELSE DO
  89.               dopus request '"Error: Could not open '''FullName'''" Again|Cancel'
  90.               again = rc
  91.             END
  92.           END
  93.         END
  94.       END
  95.     END
  96.   END
  97. END
  98.  
  99. SIGNAL quitit
  100.  
  101.  
  102. quitit:
  103.  
  104.   lister set handle title
  105.   lister refresh handle full
  106.   lister set handle busy off
  107.   EXIT
  108.